<?php

namespace App\Http\Controllers\Kms\App\Poi;

use App\Http\Controllers\BaseController;
use App\Http\Validate\Kms\Poi\PoiValidate;
use App\Service\Kms\Poi\PoiService;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class PoiController extends BaseController
{
    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface|GuzzleException
     */
    public function list(Request $request): JsonResponse
    {
        return $this->success(PoiService::list(PoiValidate::listValidate($request->all())));
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     * @throws ValidationException|GuzzleException
     */
    public function aMapList(Request $request): JsonResponse
    {
        $page     = (int)$request->get("page", 1);
        $pageSize = (int)$request->get("pageSize", 20);
        return $this->success(PoiService::aMapList(PoiValidate::aMapListValidate($request->all()), $page, $pageSize));
    }
}
